//app.js
App({
  onLaunch: function () {

    // 登录
    let that = this
    wx.clearStorageSync()
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        wx.request({

          url: this.userUrl + "/WeChat/weChatSystem/jsCodeSession",
          //测试值周
          // url: 'https://tidukeji.cn/DutyTest' + "/weChatSystem/jsCodeSession",
          method: 'POST',
          data: {
            appid: this.globalData.appid,
            // secret: this.globalData.secret,
            js_code: res.code,
            grant_type: 'authorization_code'
          },
          dataType: 'json',
          success: res => {
            this.globalData.wechatId = res.data.openid
            if (that.wechatIdCallback) {
              console.log("callback")
              that.wechatIdCallback(res)
            }
          }
        })
      }
    })
  },
  globalData: {
    appid: 'wxdb6e6538a9c8ea47',
    // secret: 'bb347eb5a2db9160d9e28f1d48f7865e',
    userId: null,
    username: null,
    realname: null,
    wechatId: null,
    departmentId: null,
    department: null,
    identityId: null,
    identity: null,
    departmentType: null,
    userType: null,
    userInfo: null,
    phone: null,
    signInSuccess: null,
    windowHeight: null,
    features: null,
  },
  // baseUrl: 'http://localhost:8083/SchoolSecurityService',
  // baseUrl: 'http://39.98.73.72:8080/SchoolSecurityService',
  // baseUrl: 'http://120.78.164.199:8080/SchoolSecurityService',
  //baseUrl: 'https://tidukeji.cn/SchoolSecurityService1',
  // baseUrl:'http://huxintest1.natapp1.cc/SchoolSecurityService' ,
  // baseUrl: 'http://ceshi.vaiwan.com/SchoolSecurityService/',
  // baseUrl:'http://localhost:8080/SchoolSecurityService' ,          
  // baseUrl: 'https://tidukeji.cn/DutyTest',  
  //   baseUrl: 'http://dingab.vaiwan.cn/SchoolSecurityService',
  baseUrl: 'http://localhost:8080/SchoolSecurityService',
  //dailyUrl: 'http://localhost:7070',
  //questionUrl: 'http://localhost:7071',
  // imageUrl:'https://tidukeji.cn',  
  imageUrl: 'https://tidu-hangzhou.oss-cn-hangzhou.aliyuncs.com',
  preUrl: 'https://tidukeji.cn',
  // imageUrl:'http://localhost:8080',           
  // imageUrl:'C://Users/yuki',       
  userUrl: "http://47.111.158.147:9527/huan/user",
  patrolUrl: "http://47.111.158.147:9527/huan/patrol",
  //inspectUrl: "http://localhost:9527/huan/inspect",
  inspectUrl: "http://47.120.32.73:8003/",
  backstageUrl: "http://47.111.158.147:9527/huan/backstage",
  zhizhouUrl: "http://47.111.158.147:9527/huan/zhizhou",
  kaoqinUrl: "http://47.111.158.147:9527/huan/backstage",
  pushUrl: "http://47.111.158.147:9527/huan/push",
  //questionnaireUrl: "http://localhost:9527/huan/questionnaire",
  questionnaireUrl: "http://47.120.32.73:8008/",
  trim(str) {
    let s = str.replace(/^[\r\n]*/g, "");
    s = s.replace(/(^\s*)|(\s*$)/g, "")
    return s;
  },

  trimAll(str) {
    return str.replace(/\s+/g, "");
  }

})